package com.xiaodu.validator.controller;

import com.xiaodu.validator.config.FileSufixx;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;

/**
 * @author: dutianjie
 * @date: 2021/3/31
 * @version: v1.0.0
 * @description: 描述
 **/
@RestController
@RequestMapping("file")
@Api(tags = "文件上传")
@Validated
@Valid
public class FileController {

    @ApiOperation(value = "上传", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public void upload(@RequestPart("file") @FileSufixx MultipartFile file) {
        System.out.println(file.getOriginalFilename());
    }
}
